public class test1 {
    //力扣  191  位1的个数
    public int hammingWeight(int n) {
        //只需每次将最右边的1去掉
        int count = 0;
        while(n!=0){
            //将右边的1去掉
            n = n&(n-1);
            count++;
        }
        return count;

    }
}
